home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 March: Reference Library / Dev.CD Mar 96 RL / Dev.CD Mar 96 RL.toast / Technical Documentation / develop / develop Issue 25 / develop Issue 25 code / QD3D to QTVR / ArticleCode / Source / NavMovie.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-21  |  2.9 KB  |  118 lines  |  [TEXT/MPCC]

  1. /*************************************************************************************************
  2.  
  3.  
  4.                 This routine makes a QTVR Navigable Movie from a Quickdraw3D model.
  5.                 
  6.                 
  7. *************************************************************************************************/                
  8. #include "QD3DtoQTVR.h"
  9. #include "extern.h"
  10. #include "NavMovie.h"
  11. #include "object.h"
  12. #include "draw.h"
  13. #include "document.h"
  14. #include "file.h"
  15. #include "AEVT.h"
  16. #include "MyMovies.h"
  17. #include "camera.h"
  18.                 
  19. void MyConvert3DMFToObject(FSSpec *myFSS)
  20. {
  21.     DocumentPtr    theDocument;
  22.     
  23.     // Create the document record and make the view and camera
  24.     theDocument = MyNewDocument();
  25.     if (!theDocument)
  26.         return;
  27.     
  28.     // Read the model and add it to the document record's group
  29.     if(MyOpenFile(myFSS, theDocument)) {
  30.         MyCloseDocument(theDocument);
  31.         return;
  32.     }
  33.     
  34.     // Set up the initial camera position for object rendering
  35.     MyInitObjCamera(theDocument);
  36.     
  37.     // Draw to the screen
  38.     MyDrawOffScreen(theDocument);
  39.     MyDrawOnScreen(theDocument);
  40.     
  41.     // Assign the Codec type
  42.     theDocument->theCodecType = kMyCodec;
  43.     
  44.     // Generate all the images and add them to the linear movie
  45.     MyGenerateObjImages(theDocument,36,19,360,0,90,-90);  // note this means 36 rows, 18 columns
  46.     
  47.     // Clean up
  48.     MyCloseDocument(theDocument);
  49. }
  50.             
  51. void MyGenerateObjImages(DocumentPtr theDocument,short rows,short columns,
  52.                           long maxHPan,long minHPan,long maxVPan,long minVPan)
  53. {
  54.     GWorldPtr            oldPort;
  55.     GDHandle            oldGD;
  56.     float                xStart,yStart,xStep,yStep;
  57.     Boolean                wrap = false;
  58.     float                xAngle,yAngle;
  59.     
  60.     GetGWorld(&oldPort,&oldGD);
  61.     SetGWorld(theDocument->theWindow,nil);
  62.     
  63.     // Create empty linear object movie
  64.     if(MyPrepareDestMovie(theDocument))
  65.         return;
  66.         
  67.     if(maxHPan == 360 && minHPan == 0) {
  68.         maxHPan = 350;
  69.         wrap = true;
  70.     }
  71.     
  72.     // Assign stepping angles
  73.     if(maxVPan == minVPan || rows == 1) 
  74.         yStep = 1;
  75.     else 
  76.         yStep = ((float)(maxVPan-minVPan))/(float)(rows-1);
  77.     
  78.     if(maxHPan == minHPan || columns == 1) 
  79.         xStep = 1;
  80.     else 
  81.         xStep = ((float)(maxHPan-minHPan))/(float)(columns-1);
  82.     
  83.     for(yAngle = maxVPan; yAngle >= minVPan; yAngle -= yStep) {
  84.         for(xAngle = 0;xAngle <= maxHPan-minHPan; xAngle += xStep) {
  85.             if(Button()) 
  86.                 break;
  87.             
  88.             // Rotate the object to the correct position
  89.             xStart = (-kQ3Pi* (  xAngle - ((float)(maxHPan-minHPan))/2.0) )/180.0;
  90.             yStart = kQ3Pi*((float)yAngle)/180.0;
  91.             MyRotateObjectY(theDocument,xStart);
  92.             MyRotateObjectX(theDocument,yStart);
  93.             
  94.             // Render the model (to get a PixMap image).
  95.             MyDrawOffScreen(theDocument);
  96.             MyDrawOnScreen(theDocument);
  97.             
  98.             // Add the rendered PixMap to the linear movie.
  99.             if(MyAddImageToMovie(theDocument)) break;
  100.             
  101.             //Undo the rotation
  102.             MyRotateObjectX(theDocument,-yStart);
  103.             MyRotateObjectY(theDocument,-xStart);
  104.         }
  105.         
  106.     }
  107.         
  108.     MyDrawOffScreen(theDocument);
  109.     MyDrawOnScreen(theDocument);
  110.     
  111.     MyCloseDestMovie(theDocument);
  112.     
  113.     SetGWorld(oldPort,oldGD);
  114. }
  115.  
  116.                                                 
  117.  
  118.